<?php
require_once('config.php');
//打开数据库连接
$db=mysqli_connect($host,$user,$password,$database);
//判断连接是否成功
if($db){
        $db->query("set names utf8");//设置UTF-8编码(JSON的唯一编码)
}else{
        echo 'DATABASE_CONNECTION_DIE';//数据库连接失败
        exit;//退出
}

//sql查询语句

$username = $_GET['username'];
$password = $_GET['password'];

//PHP随机生成6位字符串
function createRandomStr($length){
  $str = '0123456789abcdefghijklmnopqrstuvwxyz';
  $str = str_shuffle($str);
  return substr($str,0,$length);
}
$salt = createRandomStr(6);
//密码加密机制
$newpwd = md5(md5($password).$salt);


$sql = '';
$result=$db->query($sql);
while($row=$result->fetch_assoc()){
        $list[]=$row;//将取得的所有数据赋值给list数组
}
echo json_encode($list);//输出JSON
?>
